package app.kotlin_1.utils

import android.app.Activity
import android.util.Log

/**
 * Created by 刘智强 on 2017/10/24.
 * activity工具类
 *
 */
object ActivityUtils {
    private val activityList = mutableListOf<Activity>()

    fun addActivity(activity: Activity) {
        if (!activityList.contains(activity)) activityList?.add(activity!!)
    }

    fun removeActivity(activity: Activity) {
        if (activityList.contains(activity)) {
            activityList.remove(activity)
            activity.finish()
        }
    }

    fun removeAllActivitu() {
        activityList.forEach { it.finish() }
    }
    fun  getActivity(){

        activityList.forEach {  Log.e("TAG", it.javaClass.simpleName) }
//        for (actvity in activityList){
//            error(actvity.toString())
//        }

    }

}
